<?php

/**
 * Created by PhpStorm.
 * User: admin
 * Date: 2017/01/06
 * Time: 14:57
 */

define("LOGIN_SESSION", "login_flag_nw");

//--------------------------------------------------
function getLoginFlag()
{
    $reslut = false;

    if (session(LOGIN_SESSION) === "islogin")
        $reslut = true;
    else
        $reslut = false;

    return $reslut;
}

function setLoginFlag()
{
    session(LOGIN_SESSION, "islogin");
}

function setLogout()
{
    // cookie("user_disname", null);
    // session(LOGIN_SESSION, null);
    // cookie(null);
    session(null);
}

//--------------------------------------------------
function setSessionList($session_list = array())
{
    foreach ($session_list as $k => $v)
        session($k, $v);
}

function setCookieList($cookie_list = array())
{
    foreach ($cookie_list as $k => $v)
        cookie($k, $v);
}

//--------------------------------------------------
function getPassWordStr($password_str_in)
{
    $password_str = strtolower(md5(SALT_STR . $password_str_in . SALT_STR));
    $password_str = substr($password_str, 0, 15) . SALT_STR . substr($password_str, -17);
    $password_str = strtolower(md5($password_str));

    return $password_str;
}

function getTemplPath($empt_var)
{
    // $tempPath = TMPL_PATH;
    // $tempPath = substr($tempPath, 1, strlen($tempPath) - 2);
    $tempPath = TMPL_PATH_R;
    $tempPath = substr($tempPath, 0, strlen($tempPath) - 1);
    return $tempPath;
}

function getFileList($directory)
{
    $fileList = [];

    if (is_dir($directory) == true)
    {
        $mydir = dir($directory);
        while ($file = $mydir->read())
        {
            if ((is_dir($directory . "/" . $file)) AND ($file != ".") AND ($file != ".."))
            {
            }
            else if (($file != ".") AND ($file != ".."))
            {
                array_push($fileList, $file);
            }
        }
        $mydir->close();
    }

    return $fileList;
}

?>